<!DOCTYPE html>
<html>
<head>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script type="text/javascript">
$(document).ready(function(){
  $(".button").click(function(){
  $(this).next().toggle();
if($(this).text()!="收起评论")
   $(this).text("收起评论");
else $(this).text("评论数"+$(this).attr("num"));
  });
});
</script>

</head>
<body>

第一篇文章
<br>
<button class="button btn-primary" num="2">评论数2</button>
<div  style="display: none;">
                <!-- Comment -->
		<div id="abc">
                <div class="media">
                    <a class="pull-left" >
                        <img class="img-circle" alt="Cinque Terre" width="40" height="40" src="/uploads/144086480364117.png" alt="">
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">Bonster                            <small>2015-09-04 13:54:35</small>
                        </h4>
aaaaa
	              </div>
                </div>


              <div class="media">
                    <a class="pull-left" >
                        <img class="img-circle" alt="Cinque Terre" width="40" height="40" src="/uploads/144086480364117.png" alt="">
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">Bonster                            <small>2015-09-04 13:54:35</small>
                        </h4>
		bbbbb
                   </div>
                </div>
		</div>
<form  class="aaa" action="/test" title="" method="post">
<textarea class="form-control" style="width:700px;" rows="1" name="answer" id="answer"></textarea>
<input name="_token" id="_token" type="hidden" value="{{csrf_token()}}">
<input type="submit" id="submitButton"  name="submitButton" value="Submit">
</form>


</div>


<br>
第二篇文章
<br>
<button class="button btn-primary" num="3">评论数3</button>
<div style="display: none;">
                <!-- Comment -->
                <div class="media">
                    <a class="pull-left" >
                        <img class="img-circle" alt="Cinque Terre" width="40" height="40" src="/uploads/144086480364117.png" alt="">
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">Bonster                            <small>2015-09-04 13:54:35</small>
                        </h4>
cccccc
                  </div>
                </div>


              <div class="media">
                    <a class="pull-left" >
                        <img class="img-circle" alt="Cinque Terre" width="40" height="40" src="/uploads/144086480364117.png" alt="">
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">Bonster                            <small>2015-09-04 13:54:35</small>
                        </h4>
			用编程，一天，用数列，1分钟                    </div>
                </div>

<form  class="aaa" action="/test" title="" method="post">
<textarea class="form-control" style="width:700px;" rows="1" name="answer" id="answer"></textarea>
<input name="_token" id="_token" type="hidden" value="{{csrf_token()}}">
<input type="submit" id="submitButton"  name="submitButton" value="Submit">
</form>
</div>

<br>
end
<script type='text/javascript'>
    /* attach a submit handler to the form */
    $(".aaa").submit(function(event) {
      /* stop form from submitting normally */
      event.preventDefault();

      /* get some values from elements on the page: */
      var $form = $( this ),
          url = $form.attr( 'action');
	  var ans=$(this).find("[name='answer']").val();
          $(this).prev().append(' <div class="media"><a class="pull-left"> <img class="img-circle" alt="Cinque Terre" width="40" height="40" src="/uploads/144086480364117.png" alt=""></a><div class="media-body"><h4 class="media-heading">Bonster<small>2015-09-04 13:54:35</small></h4>'+ans+'</div></div>');
	  $(this).find("[name='answer']").val("");
      /* Send the data using post */
      var posting = $.post( url, { comment: ans,_token:$(this).find("[name='_token']").val()});

      /* Alerts the results */
      posting.done(function( data ) {
		     // var div=document.getElementById("abc");
      });
    });
</script>
</body>
</html>

